import{d as y,k,c as u,o as r,w as s,a as v,q as C,e as m,t as i,b as V,bH as b,u as n,y as x,f as D,S as f,g as p,j as g,bI as A,U as B,bJ as N}from"./CtbHscGXagutd.js";const S=y({__name:"tw-dialog",props:{title:{},message:{},mode:{},cancel:{},confirm:{},done:{},placeholder:{},defaultValue:{}},setup(a){const t=a,o=k(String(t.defaultValue??""));function c(){t.mode==="prompt"?t.done?.(o.value):t.done?.(!0)}function e(){t.mode==="prompt"?t.done?.(null):t.done?.(!1)}return(l,d)=>(r(),u(n(A),{class:"tw-dialog",active:"",standalone:"",close:!1,title:a.title,onClose:e},{footer:s(()=>[D(n(f),{onClick:e},{default:s(()=>[p(i(a.cancel??n(g)("dialog.cancel")),1)]),_:1}),a.mode==="confirm"||a.mode==="prompt"?(r(),u(n(f),{key:0,onClick:c},{default:s(()=>[p(i(a.confirm??n(g)("dialog.ok")),1)]),_:1})):m("",!0)]),default:s(()=>[v("div",null,i(a.message),1),a.mode==="prompt"?C((r(),V("input",{key:0,"onUpdate:modelValue":d[0]||(d[0]=w=>o.value=w)},null,512)),[[b,o.value],[n(x)]]):m("",!0)]),_:1},8,["title"]))}});function T(a=S){let t;async function o(e){const l=N(a,e);return t=l.cancel,l.awaitDone}const c=B();return c.add(()=>t?.()),{dispose:c,async alert(e){return await o({message:e,cancel:"OK",mode:"alert"})},async confirm(e){return await o({message:e,mode:"confirm"})},async prompt(e,l){return await o({message:e,defaultValue:l??"",mode:"prompt"})},async dialog(e){return await o(e)},async open(e){return await o(e??{})}}}export{T as u};